#pragma once
#include <iostream>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

class addr_t
{

public:
    addr_t(){}
    addr_t(sockaddr_in &addr) : _addr(addr)
    {
        _ip = inet_ntoa(addr.sin_addr);
        _port = ntohs(addr.sin_port);
    }


    std::string Ip()
    {
        return _ip;
    }

    u_int16_t Port()
    {
        return _port;
    }

    sockaddr_in* Addr() 
    {
        return &_addr;
    }

    socklen_t Len()
    {
        return sizeof(_addr);
    }

private:
    std::string _ip;
    u_int16_t _port;

    sockaddr_in _addr;
};